﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Application.Admin.Report
{
    public class ReportService : IReportService
    {
        Application.Admin.Sight.ISightPointService sightService;

        Application.Admin.MobileClient.IMobileClientService clientService;

        Application.Admin.Sight.ISightPointCommService commService;

        Application.Admin.Sight.ISightPointUserSiginService siginService;

        public ReportService(Application.Admin.Sight.ISightPointService sight,
            Application.Admin.MobileClient.IMobileClientService client,
            Application.Admin.Sight.ISightPointCommService comm,
            Application.Admin.Sight.ISightPointUserSiginService sigin)
        {
            if (sight == null)
            {
                throw new ArgumentNullException("sightService is null");
            }
            if (client == null)
            {
                throw new ArgumentNullException("clientService is null");
            }
            if (client == null)
            {
                throw new ArgumentNullException("clientService is null");
            }
            if (client == null)
            {
                throw new ArgumentNullException("clientService is null");
            }
            sightService = sight;
            clientService = client;
            commService = comm;
            siginService = sigin;
        }

        //今日 ，昨天 ，一周 ，一个月，
        //签到量
        public int GetSightSiginReport(DateTime time)
        {
            var data = siginService.GetList()
                .Where(e => e.AddTime >= time)
                .Count();
            return data;
        }

        public int GetSightSiginTodayReport()
        {
            var time = DateTime.Parse(System.DateTime.Now.ToString("yyyy-MM-dd"));
            var count = GetSightSiginReport(time);
            return count;
        }

        public int GetSightSiginYesterdayReport()
        {
            var time = DateTime.Parse(System.DateTime.Now.ToString("yyyy-MM-dd")).AddDays(-1);
            var count = GetSightSiginReport(time);
            return count;
        }

        public int GetSightSiginWeekReport()
        {
            var time = DateTime.Parse(System.DateTime.Now.ToString("yyyy-MM-dd")).AddDays(-7);
            var count = GetSightSiginReport(time);
            return count;
        }

        public int GetSightSiginMonthReport()
        {
            var time = DateTime.Parse(System.DateTime.Now.ToString("yyyy-MM-dd")).AddMonths(-1);
            var count = GetSightSiginReport(time);
            return count;
        }

        ////今日 ，昨天 ，一周 ，一个月，
        //评论数
        public int GetSightCommReport(DateTime time)
        {
            var data = commService.GetList()
                .Where(e => e.AddTime >= time)
                .Count();
            return data;
        }

        public int GetSightCommTodayReport()
        {
            var time = DateTime.Parse(System.DateTime.Now.ToString("yyyy-MM-dd"));
            var count = GetSightCommReport(time);
            return count;
        }

        public int GetSightCommYesterdayReport()
        {
            var time = DateTime.Parse(System.DateTime.Now.ToString("yyyy-MM-dd")).AddDays(-1);
            var count = GetSightCommReport(time);
            return count;
        }

        public int GetSightCommWeekReport()
        {
            var time = DateTime.Parse(System.DateTime.Now.ToString("yyyy-MM-dd")).AddDays(-7);
            var count = GetSightCommReport(time);
            return count;
        }

        public int GetSightCommMonthReport()
        {
            var time = DateTime.Parse(System.DateTime.Now.ToString("yyyy-MM-dd")).AddMonths(-1);
            var count = GetSightCommReport(time);
            return count;
        }

        //今日 ，昨天 ，一周 ，一个月，
        //新增客户端
        public int GetNewClientReport(DateTime time)
        {
            var data = clientService.GetList()
                .Where(e => e.AddTime >= time)
                .Count();
            return data;
        }

        public int GetNewClientTodayReport()
        {
            var time = DateTime.Parse(System.DateTime.Now.ToString("yyyy-MM-dd"));
            var count = GetNewClientReport(time);
            return count;
        }

        public int GetNewClientYesterdayReport()
        {
            var time = DateTime.Parse(System.DateTime.Now.ToString("yyyy-MM-dd")).AddDays(-1);
            var count = GetNewClientReport(time);
            return count;
        }

        public int GetNewClientWeekReport()
        {
            var time = DateTime.Parse(System.DateTime.Now.ToString("yyyy-MM-dd")).AddDays(-7);
            var count = GetNewClientReport(time);
            return count;
        }

        public int GetNewClientMonthReport()
        {
            var time = DateTime.Parse(System.DateTime.Now.ToString("yyyy-MM-dd")).AddMonths(-1);
            var count = GetNewClientReport(time);
            return count;
        }
    }
}
